﻿<!--<span data-bind="text: ko.toJSON($data)"></span>-->

<!-- ko if: LoadedDef() &&  $root.Definition.Filters && $root.Definition.Filters.length -->
<a href="#" type="button" data-toggle="collapse" data-target=".filter-wrapper">Filters
</a>
<div class="collapse filter-wrapper">
    <div data-bind="if: $root.Definition.Filters != null" class="filters">
        <table>
            <tbody>
                <!-- ko foreach: $root.Definition.Filters -->
                <tr>
                    <td class="filter-label" data-bind="text: Label"></td>
                    <td data-bind="filterFor : {Field : $data}"></td>
                </tr>
                <!-- /ko -->
                <tr>
                    <td></td>
                    <td><a class="btn" href="#" data-bind="click:$root.applyFilters">Apply</a></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<!-- /ko -->

<!-- ko if: LoadedDef() && Loaded() -->

<!-- ko if: Items().length -->
<table class="table table-striped">
    <thead>
        <tr data-bind="template: { name: 'GridHeaders' }">

        </tr>
    </thead>
    <tbody data-bind="foreach: Items">
        <tr>
            <td data-bind="if: $root.DefaultAction || ($root.Actions && $root.Actions.length)">
                <div class="btn-group">
                    <!-- ko if: $root.DefaultAction -->
                    <a class="btn" data-bind="actionFor:{action : $root.DefaultAction, item : $data}">Action</a>
                    <button class="btn dropdown-toggle" data-toggle="dropdown">
                        <span class="caret"></span>
                    </button>
                    <!-- /ko -->
                    <!-- ko if: !$root.DefaultAction -->
                    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Action <span class="caret"></span>
                    </a>
                    <!-- /ko -->
                    <ul class="dropdown-menu" data-bind="foreach: $root.Actions">
                        <li><a href="#" data-bind="actionFor:{action : $data, item : $parent}"></a></li>
                    </ul>
                </div>
            </td>
            <!-- ko template: {name : 'GridRow'} -->
            <!-- /ko -->
        </tr>
    </tbody>
</table>

<!-- /ko -->
<!-- ko if: Items().length === 0 -->
<h3 data-bind="res: 'msg_no_data'"></h3>
<!-- /ko -->
<div data-bind="foreach: $root.GlobalActions">
    <a class="btn" href="#" data-bind="actionFor:{action : $data}"></a>
</div>

<!-- /ko -->
